package service.Impl;

import dao.DoctorWorkDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import pojo.DoctorWork;
import service.DoctorWorkService;

import java.util.List;

@Service
public class DoctorWorkServiceImpl implements DoctorWorkService {

    @Autowired
    private DoctorWorkDao doctorWorkDao;

    @Override
    public List<DoctorWork> getDoctorWorkByDay(String day) {
        return doctorWorkDao.selectAllInfo(day);
    }

    @Override
    @Transactional
    public boolean decreaseCountLeft(String day, String docId) {
        try {
            doctorWorkDao.updateCountLeftById(day, docId);
            return true;
        } catch (Exception e) {
            // 记录日志
            return false;
        }
    }

    @Override
    @Transactional
    public boolean increaseCountLeft(String day, String docId) {
        try {
            doctorWorkDao.updateCountLeftById2(day, docId);
            return true;
        } catch (Exception e) {
            // 记录日志
            return false;
        }
    }
}